from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import as_completed
from pratice_threading import blog_spider

with ThreadPoolExecutor() as pool:
    response_html = pool.map(blog_spider.get_blog_response, blog_spider.urls)
    temp_html = list(zip(blog_spider.urls, response_html))
    for url, html in temp_html:
        print(url, len(html))

with ThreadPoolExecutor() as pool:
    futures = []
    for url, html in temp_html:
        future = pool.submit(blog_spider.get_blog_links, html)
        futures.append(future)

    # for temp_future, temp_url in futures.items():
    #     print(url, temp_future.result())

    for temp_future in as_completed(futures):
        print(temp_future.result())
